﻿using Microsoft.SemanticKernel;
using System.ComponentModel;
using System.Text.Json.Serialization;

namespace semantic_kernel_api
{
    public class DefaultTool
    {

        /// <summary>
        /// 加法运算
        /// </summary>
        /// <returns></returns>
        [KernelFunction("Add")]
        [Description("加法运算")]
        public async Task<ResultModel> Add(double num1, double num2)
        {
            var ret = new ResultModel();
            ret.data = num1 + num2;
            return ret;
        }



        /// <summary>
        /// 减法运算
        /// </summary>
        /// <returns></returns>
        [KernelFunction("Subtraction")]
        [Description("减法运算")]
        public async Task<ResultModel> Subtraction(double num1, double num2)
        {
            var ret = new ResultModel();
            ret.data = num1 - num2;
            return ret;

        }


        /// <summary>
        /// 乘法运算
        /// </summary>
        /// <returns></returns>
        [KernelFunction("Multiplication")]
        [Description("乘法运算")]
        public async Task<ResultModel> Multiplication(double num1, double num2)
        {
            var ret = new ResultModel();
            ret.data = num1 * num2;
            return ret;

        }


        /// <summary>
        /// 除法运算
        /// </summary>
        /// <returns></returns>
        [KernelFunction("Division")]
        [Description("除法运算")]
        public async Task<ResultModel> Division(double num1, double num2)
        {
            var ret = new ResultModel();
            ret.data = num1 / num2;
            return ret;

        }


        /// <summary>
        /// 计算平方根
        /// </summary>
        /// <returns></returns>
        [KernelFunction("Sqrt")]
        [Description("计算平方根")]
        public async Task<ResultModel> Sqrt(double num)
        {
            var ret = new ResultModel();
            ret.data = Math.Sqrt(num);
            return ret;

        }

        /// <summary>
        /// 计算绝对值
        /// </summary>
        /// <returns></returns>
        [KernelFunction("Abs")]
        [Description("计算绝对值")]
        public async Task<ResultModel> Abs(double num)
        {
            var ret = new ResultModel();
            ret.data = Math.Abs(num);
            return ret;

        }


        /// <summary>
        /// 计算最大值
        /// </summary>
        /// <returns></returns>
        [KernelFunction("Max")]
        [Description("计算最大值")]
        public async Task<ResultModel> Max(double num1, double num2)
        {
            var ret = new ResultModel();
            ret.data = Math.Max(num1, num2);
            return ret;


        }


        /// <summary>
        /// 计算最小值
        /// </summary>
        /// <returns></returns>
        [KernelFunction("Min")]
        [Description("计算最小值")]
        public async Task<ResultModel> Min(double num1, double num2)
        {
            var ret = new ResultModel();
            ret.data = Math.Min(num1, num2);
            return ret;
        }
        /// <summary>
        /// 计算余弦值
        /// </summary>
        /// <returns></returns>
        [KernelFunction("Cos")]
        [Description("计算余弦值")]
        public async Task<ResultModel> Cos(double num)
        {
            var ret = new ResultModel();
            ret.data = Math.Cos(num);
            return ret;

        }


       



    }
}

public class ResultModel
{
    [JsonPropertyName("计算结果")]
    public object data { get; set; }

}